#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
map<LL,LL>map1,map2;
bool vis[maxn];
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL m,n;cin>>m>>n;
  for(LL i=1;i<=m;i++){
     LL x;cin>>x;
     string a;cin>>a;
     map2[x]++;
     if(a=="AC") map1[x]++;
     if(map1[x]*1.0/(1.0*map2[x])<0.5) {
            vis[x]=1;
     }
  }
  for(LL i=1;i<=n;i++){
    if(!map2.count(i)) vis[i]=1;
  }
  LL sum=0;
  for(LL i=1;i<=n;i++){
    if(vis[i]==0) cout<<i<<" ",sum++;
  }
  if(sum==0){
    cout<<"-1"<<"\n";
  }
  else cout<<"\n";
return 0;
}
